package com.seannews.server.Service.ServiceImpl;

import com.seannews.server.Dao.NewsDao;
import com.seannews.server.Pojo.Basicinfo;
import com.seannews.server.Pojo.Basicinfo2;
import com.seannews.server.Pojo.News;
import com.seannews.server.Pojo.Newstype;
import com.seannews.server.Service.NewsService;
import com.seannews.server.helper.Demo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class NewsServiceImpl implements NewsService {
    @Resource
    NewsDao newsDao;
    @Override
    public List<News> getNewsList(String type) {
        return newsDao.getNewsList(type);
    }

    @Override
    public List<News> getNewsall(int start,int stop,String title,String newsId,String category) {
        return newsDao.getNewsall(start,stop,title,newsId,category);
    }
    public int getnewscount(){
        return newsDao.getnewscount();
    }
    public void deletenews(String newsId){
        newsDao.deletenews(newsId);
    }
    @Override
    public List<Newstype> getNewstypecount() {
        return newsDao.getNewstypecount();
    }

    @Override
    public News getNewbyid(String newsId,String userId) {
        newsDao.adduserread(userId);
        newsDao.Newsvisitadd(newsId);
        return newsDao.getNewbyid(newsId);
    }

    @Override
    public Basicinfo getBasicinfo() {
        Basicinfo basicInfo = new Basicinfo();
        basicInfo.setNewscount(newsDao.getnewscount());
        basicInfo.setSynthesis(newsDao.getsynthesis());
        basicInfo.setUsercount(newsDao.getusercount());
        basicInfo.setVisitcount(newsDao.getvisitcount());
        return basicInfo;
    }

    @Override
    public Basicinfo2 getBasicinfo2() {
        Basicinfo2 basicinfo2=new Basicinfo2();
        basicinfo2.setNewsitemcount(newsDao.getnewsitemcount());
        basicinfo2.setVisitcount(newsDao.getvisitcount());
        basicinfo2.setNewslistcount(newsDao.getnewslistcount());
        basicinfo2.setTodayvisitcount(newsDao.gettodayvisitcount());
        return basicinfo2;
    }

    @Override
    public List<Newstype> getvisitbytype() {
        return newsDao.getvisitbytype();
    }
    public List<Newstype> getdatecount(){
        return newsDao.getdatecount();
    }
}
